Belgelerim/ceng_491/implementation/doxygen/TraffEdu_Developers_Manual_Reference_ToSource/CommandText.cpp

Go to the documentation of this file.
00001 #include "CommandText.h"
00002 
00003 
00004 CommandText::CommandText(OSGWindows *osgwind)
00005 {
00006         osgwind_=osgwind;
00007     geode = new osg::Geode();
00008         text = new osgText::Text; 
00009 }
00010 
00011 
00012 CommandText::~CommandText()
00013 {  
00014 
00015 }
00016 
00017 osg::ref_ptr<osg::Geode> CommandText::createText(string str)
00018 {
00019    osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f);
00020         text->setColor(layoutColor);
00021 
00022    text->setText (str);
00023    text->setFont ("fonts/arial.ttf");
00024    text->setPosition (osg::Vec3 (10.0f, 600.0f, 0.0f));
00025    text->setCharacterSize (50.0);
00026 
00027    geode->addDrawable (text.get());
00028 
00029    
00030    return geode;
00031 }
00032 
00033 osg::ref_ptr<osg::Projection>  CommandText::CreateHUD (osg::ref_ptr<osg::Geode> hudGeometry,
00034                                          int width, int height,
00035                                          int binNumber,
00036                                          const char* binName)
00037 {
00038    osg::ref_ptr<osg::StateSet> stateSet = hudGeometry->getOrCreateStateSet();
00039    stateSet->setMode (GL_LIGHTING, osg::StateAttribute::OFF);
00040    stateSet->setMode (GL_DEPTH_TEST, osg::StateAttribute::OFF);
00041    stateSet->setRenderBinDetails (binNumber, binName);
00042 
00043    osg::ref_ptr<osg::MatrixTransform> modelviewAbs (new osg::MatrixTransform);
00044    modelviewAbs->setReferenceFrame (osg::Transform::ABSOLUTE_RF);
00045    modelviewAbs->setMatrix (osg::Matrix::identity());
00046 
00047    modelviewAbs->addChild (hudGeometry.get());
00048 
00049    osg::ref_ptr<osg::Projection> projection (new osg::Projection());
00050    projection->setMatrix (osg::Matrix::ortho2D (0, width, 0, height));
00051    projection->addChild (modelviewAbs.get());
00052 
00053    return projection;
00054 }
00055 
00056 osg::ref_ptr<osg::Group> CommandText::createTextGroup()
00057 {
00058 
00059         osg::ref_ptr<osg::Group> group = new osg::Group;
00060 
00061     osg::Sequence* seq = new osg::Sequence;
00062     group->addChild(seq);
00063         int flag=0;
00064         for (int i=0;i<101;i++) {
00065                 osg::ref_ptr<osg::Group> tmp=new osg::Group; 
00066                 for(int j=0;j<osgwind_->getTextArray().size();j++)
00067                 {
00068                         
00069                         if(i==osgwind_->getTextArray()[j]->frameNum)
00070                         {
00071                                 
00072                                 seq->addChild(osgwind_->getTextArray()[j]->textGroup.get());
00073                                 seq->setTime(seq->getNumChildren()-1, 3.0f);
00074                                 flag=1;
00075                         }
00076                 }
00077                 if(!flag && i>=osgwind_->getFrames()[0]->getFrameId())
00078                 {
00079                         seq->addChild(tmp.get());
00080                         seq->setTime(seq->getNumChildren()-1,1.0f);
00081                 }
00082                 flag=0;
00083     }
00084 
00085     seq->setInterval(osg::Sequence::LOOP, 0,-1);
00086 
00087     seq->setDuration(1.0f, -1);
00088 
00089     seq->setMode(osg::Sequence::START);
00090 
00091     return group;
00092 }
00093 
00094 
00095 
00096 /*CommandText::deleteText()
00097 {
00098         
00099 }*/

Generated on Sun May 28 18:54:09 2006 for TraffEdu by  doxygen 1.4.6-NO